﻿#include "MenuScene.h"
#include "ShareComponents.h"
#include "RSManager.h"
#include "StateManager.h"
#include "MainGame.h"

MenuScene::MenuScene(HINSTANCE hIns, char* windowName, int w, int h) :FWGame(hIns, windowName, w,h)
{

}
MenuScene::MenuScene(FWGame* fwgame) : FWGame(fwgame)
{
	id_scene= MENU;
}

MenuScene::~MenuScene()
{

}
void MenuScene::load()
{
	_cam = new Camera(0,1024,480);
	_background = RSManager::getInstance()->getSprite(MENU_BACKGROUND);
	_option_icon = RSManager::getInstance()->getSprite(OPTION_ICON);
	_background_pos = D3DXVECTOR2(this->Width, 0);
	_icon_pos = D3DXVECTOR2(this->Width, 140);
	cam_pos.x =255;
	cam_pos.y = 0;
	_is_oneplayer = true;
	_is_press_enter = false;
	_isrender = true;
	delay = 0;
}
void MenuScene::update(float time)
{
	delay += GAME_TIME;
	if(delay > 20)
	{
		cam_pos.x+= 5;
		delay = 0;
	}
	_cam->update(cam_pos);
	

}
void MenuScene::render()
{
	gl_graphic->begin(_cam->getTransformedMatrix());
	_background->Render(_background_pos);
	gl_graphic->sDraw("PLAYER SELECT",_background_pos + D3DXVECTOR2(60,160),D3DCOLOR_XRGB(188,188,188));
	gl_graphic->sDraw("UIT @ 2014",
	_background_pos + D3DXVECTOR2(300,80) ,D3DCOLOR_XRGB(188,188,188));
	gl_graphic->sDraw("GAME DEVELOMENT-DINH NGUYEN ANH DUNG\n         LICENSED BY LUAN, TUYEN, THAO ",
	_background_pos + D3DXVECTOR2(10,50) ,D3DCOLOR_XRGB(188,188,188));
	gl_graphic->sDraw("1  PLAYER", _background_pos + D3DXVECTOR2(90,130),D3DCOLOR_XRGB(188,188,188));
	gl_graphic->sDraw("2  PLAYERS", _background_pos + D3DXVECTOR2(90,100),D3DCOLOR_XRGB(188,188,188));
	 	if (_background_pos.x==0)
			_option_icon->Render(_icon_pos);
	 	if (!_is_press_enter)
	 	{

	 
	 	}
	 	else 
	 	{
	 		if((_isrender)|| (_is_oneplayer && !_isrender ))
	 			gl_graphic->sDraw("2  PLAYERS", _background_pos + D3DXVECTOR2(120,350),D3DCOLOR_XRGB(188,188,188));
	 		if((_isrender)|| (!_is_oneplayer && !_isrender ))
	 			gl_graphic->sDraw("1  PLAYER", _background_pos + D3DXVECTOR2(120,320),D3DCOLOR_XRGB(188,188,188));		
	 	}
	gl_graphic->end();
}
void MenuScene::shutdown()
{

}